﻿using System;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ornament.Util.NHibernateHelper;

public partial class Admin_System_Controls_NhibernateControls_RuntimeSetting : UserControl
{
    public void UpdateValueOn(SessionFactory sessionFactory)
    {
        sessionFactory.Runtime.Timeout = Convert.ToInt32(TimeoutTextBox.Text);
        sessionFactory.Runtime.UseOuterJoin = UseOuterJoinCheckBox.Checked;
        sessionFactory.Runtime.BatchSize = Convert.ToInt32(BatchSizeTextBox.Text);
        sessionFactory.Runtime.Isolation =
            (IsolationLevel)Enum.Parse(typeof(IsolationLevel), IsoLevelDropDownList.SelectedValue);
    }

    public void DataBind(SessionFactory sessionFactory)
    {
        TimeoutTextBox.Text = sessionFactory.Runtime.Timeout.ToString();
        UseOuterJoinCheckBox.Checked = sessionFactory.Runtime.UseOuterJoin;
        BatchSizeTextBox.Text = sessionFactory.Runtime.BatchSize.ToString();
        IsoLevelDropDownList.SelectedValue = sessionFactory.Runtime.Isolation.ToString();
    }
  
    protected void InitIsolationLevel(object sender, EventArgs e)
    {
        var c =(DropDownList)sender;
        c.DataSource = Enum.GetValues(typeof(IsolationLevel));
        c.DataBind();
    }
}